package ckw.gui;

import org.eclipse.jface.wizard.Wizard;

import ckw.database.model.Election;

public class WzdAddEditElection extends Wizard {

	private boolean addElection;
	private Election election;

	private WzdPgAddEditElectionBasicData wzdPgAddEditElectionBasicData;
	private WzdPgAddEditElectionRKWs wzdPgAddEditElectionRKWs;
	private WzdPgAddEditElectionRKWMembers wzdPgAddEditElectionRKWMembers;
	private WzdPgAddEditElectionRKWVoters wzdPgAddEditElectionRKWVoters;
	private WzdPgAddEditElectionCards wzdPgAddEditElectionCards;

	public WzdAddEditElection(boolean addElection, Election election) {
		if (addElection) {
			setWindowTitle("Add Election");
		} else {
			setWindowTitle("Edit Election");
		}

		this.addElection = addElection;
		this.election = election;
	}

	protected WzdPgAddEditElectionBasicData getWzdPgAddEditElectionBasicData() {
		return wzdPgAddEditElectionBasicData;
	}

	protected WzdPgAddEditElectionRKWs getWzdPgAddEditElectionRKWs() {
		return wzdPgAddEditElectionRKWs;
	}

	protected WzdPgAddEditElectionRKWMembers getWzdPgAddEditElectionRKWMembers() {
		return wzdPgAddEditElectionRKWMembers;
	}

	protected WzdPgAddEditElectionRKWVoters getWzdPgAddEditElectionRKWVoters() {
		return wzdPgAddEditElectionRKWVoters;
	}

	protected WzdPgAddEditElectionCards getWzdPgAddEditElectionCards() {
		return wzdPgAddEditElectionCards;
	}

	@Override
	public void addPages() {
		wzdPgAddEditElectionBasicData = new WzdPgAddEditElectionBasicData(addElection, election);
		addPage(wzdPgAddEditElectionBasicData);
		wzdPgAddEditElectionRKWs = new WzdPgAddEditElectionRKWs(addElection, election);
		addPage(wzdPgAddEditElectionRKWs);
		wzdPgAddEditElectionRKWMembers = new WzdPgAddEditElectionRKWMembers(addElection, election);
		addPage(wzdPgAddEditElectionRKWMembers);
		wzdPgAddEditElectionRKWVoters = new WzdPgAddEditElectionRKWVoters(addElection, election);
		addPage(wzdPgAddEditElectionRKWVoters);
		wzdPgAddEditElectionCards = new WzdPgAddEditElectionCards(addElection, election);
		addPage(wzdPgAddEditElectionCards);
	}

	@Override
	public boolean performFinish() {
		wzdPgAddEditElectionBasicData.update();
		wzdPgAddEditElectionRKWs.update();
		wzdPgAddEditElectionRKWMembers.update();
		wzdPgAddEditElectionRKWVoters.update();
		wzdPgAddEditElectionCards.update();
		return true;
	}

}
